import { IPSDEUILogic } from './ipsdeuilogic';
import { IPSDEUILogicParam } from './ipsdeuilogic-param';
import { IPSDEUIMsgBoxLogic } from './ipsdeuimsg-box-logic';
import { PSDEUILogicNodeImpl } from './psdeuilogic-node-impl';

export class PSDEUIMsgBoxLogicImpl extends PSDEUILogicNodeImpl implements IPSDEUIMsgBoxLogic {
  get buttonsType(): 'YESNO' | 'YESNOCANCEL' | 'OK' | 'OKCANCEL' {
    return this.M.buttonsType;
  }

  protected dstpsdeuilogicparam: IPSDEUILogicParam | null = null;

  getDstPSDEUILogicParam(): IPSDEUILogicParam | null {
    if (this.dstpsdeuilogicparam != null) return this.dstpsdeuilogicparam;
    const value = this.M.getDstPSDEUILogicParam;
    if (value == null) {
      return null;
    }
    const ipsdeuilogic = this.getParentPSModelObject('dataentity.logic.IPSDEUILogic') as IPSDEUILogic;
    if (ipsdeuilogic != null) {
      this.dstpsdeuilogicparam = ipsdeuilogic.findPSDEUILogicParam(value);
    }
    return this.dstpsdeuilogicparam;
  }

  get dstPSDEUILogicParam(): IPSDEUILogicParam | null {
    return this.getDstPSDEUILogicParam();
  }

  getDstPSDEUILogicParamMust(): IPSDEUILogicParam {
    const value = this.getDstPSDEUILogicParam();
    if (value == null) {
      throw new Error('未指定目标逻辑参数对象');
    }
    return value;
  }

  get message(): string {
    return this.M.message;
  }

  protected msgboxparam: IPSDEUILogicParam | null = null;

  getMsgBoxParam(): IPSDEUILogicParam | null {
    if (this.msgboxparam != null) return this.msgboxparam;
    const value = this.M.getMsgBoxParam;
    if (value == null) {
      return null;
    }
    const ipsdeuilogic = this.getParentPSModelObject('dataentity.logic.IPSDEUILogic') as IPSDEUILogic;
    if (ipsdeuilogic != null) {
      this.msgboxparam = ipsdeuilogic.findPSDEUILogicParam(value);
    }
    return this.msgboxparam;
  }

  get msgBoxParam(): IPSDEUILogicParam | null {
    return this.getMsgBoxParam();
  }

  getMsgBoxParamMust(): IPSDEUILogicParam {
    const value = this.getMsgBoxParam();
    if (value == null) {
      throw new Error('未指定消息框参数对象');
    }
    return value;
  }

  get msgBoxType(): 'INFO' | 'QUESTION' | 'WARNING' | 'ERROR' {
    return this.M.msgBoxType;
  }

  get showMode(): 'CENTER' {
    return this.M.showMode;
  }

  get title(): string {
    return this.M.title;
  }

  get cls(): string {
    return 'PSDEUIMsgBoxLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.logic.IPSDEUIMsgBoxLogic') return true;
    return super.instanceof(cls);
  }
}
